#pragma once 

namespace xmlredirect
{
	class Extracter
	{
	public:
		class Context : private hc::noncopyable
		{
			friend Extracter;
			typedef boost::signals2::signal<void (RawMaterial&)> OnMaterialFounded;
		public:
			typedef OnMaterialFounded::slot_type OnMaterialFoundedType;

			Context(const string& path);
			void AddHandler( const OnMaterialFoundedType& slot );
		private:
			OnMaterialFounded m_onMaterialFounded;
			string m_xPath;
		};
		typedef boost::shared_ptr<Context> SContext;

	public: 
		explicit Extracter(const string& xmlName);
		explicit Extracter(xml::pdocument xmlDoc);

		void Add(const SContext contextOfSearching);
		void Run();
		
	private:
		void Parse(SContext contextOfSearching, const xml::pnode& node, const string& xPath);
		RawMaterial Extact(xml::pnode& node);

		list<SContext> m_Contexts;
		xml::pdocument m_xml;
	};
}